export default {
  totalMoney (state) {
    // console.log(state.cart)
    const money = state.cart.reduce((money, shop) => {
      // console.log(money)
      if (shop.check) {
        money += shop.price * shop.count
      }
      // console.log(typeof money)
      return money
    }, 0)
    // console.log(state.cart)
    return money
  },
  isAllCheck (state) {
    // 遍历每一个shop只要一个为false就返回false
    return state.cart.length === 0 ? false : state.cart.every(shop => shop.check)
  },
  totleCount ({ cart }) {
    const a = cart.reduce((count, shop) => {
      return count + shop.count
    }, 0)
    return a
  }
}
